﻿<UserControl x:Class="CodeAbility.MonitorAndCommand.WpfMonitor.UserControls.MCP4921"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:converters="clr-namespace:CodeAbility.MonitorAndCommand.WpfMonitor.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="250" d:DesignWidth="250">
    
    <UserControl.Resources>
        <converters:VoltageToOpacityConverter x:Key="VoltageToOpacity" />
    </UserControl.Resources>
    
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="160"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" Text="MCP4921" Style="{StaticResource DeviceNameStyle}"></TextBlock>

        <Ellipse Grid.Row="1" Fill="Red" 
                    Height="100" Width="100"
                    Stroke="White" StrokeThickness="3"
                    Opacity="{Binding Voltage, Converter={StaticResource VoltageToOpacity}, FallbackValue=0.1}"
                    HorizontalAlignment="Center" VerticalAlignment="Center"/>

        <TextBlock Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Voltage, StringFormat='\{0\}V'}" FontSize="24" Foreground="White"></TextBlock>

    </Grid>
</UserControl>
